package validator

import (
	"context"
	"github.com/go-playground/validator/v10"
	"reflect"
	"regexp"
	"store/libs/helper"
)

func phone(ctx context.Context, fl validator.FieldLevel) bool {
	field := fl.Field()
	phone := ""
	if field.Kind() == reflect.Int64 {
		phone = helper.ToString(field.Int())
	} else {
		phone = field.String()
	}

	matched, _ := regexp.Match("^1[3-9][0-9]9$", []byte(phone))
	return matched
}
